/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.projektjava;

import java.io.File;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLNonTransientConnectionException;
import java.util.List;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.sql.DataSource;
import junit.framework.TestCase;
import cz.muni.fi.pv168.common.DBUtils;
import org.apache.commons.dbcp.BasicDataSource;

/**
 *
 * @author Michal Polkorab
 */
public class CompanyDAOImplTest extends TestCase {
    
    private CompanyDAOImpl manager;
    private DataSource ds;

    private static DataSource prepareDataSource() throws SQLException {
        BasicDataSource ds = new BasicDataSource();
        //we will use in memory database
        ds.setUrl("jdbc:derby:memory:invoicemgr-test;create=true");
        return ds;
    }
    
    public CompanyDAOImplTest(String testName) {
        super(testName);
    }
    
    
    public void setUp() throws SQLException {
        ds = prepareDataSource();
        DBUtils.executeSqlScript(ds,CompanyDAOImpl.class.getResource("createTables.sql"));
        manager = new CompanyDAOImpl();
        manager.setDataSource(ds);
    }

    
    public void tearDown() throws SQLException {
        DBUtils.executeSqlScript(ds,CompanyDAOImpl.class.getResource("dropTables.sql"));
    }

    /**
     * Test of create method, of class CompanyDAOImpl.
     */
    public void testCreate() {
        System.out.println("create");
        Company company = null;
        CompanyDAOImpl instance = new CompanyDAOImpl();
        instance.create(company);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of remove method, of class CompanyDAOImpl.
     */
    public void testRemove() {
        System.out.println("remove");
        Company company = null;
        CompanyDAOImpl instance = new CompanyDAOImpl();
        instance.remove(company);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of update method, of class CompanyDAOImpl.
     */
    public void testUpdate() {
        System.out.println("update");
        Company company = null;
        CompanyDAOImpl instance = new CompanyDAOImpl();
        instance.update(company);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of find method, of class CompanyDAOImpl.
     */
    public void testFind() {
        System.out.println("find");
        Long id = null;
        CompanyDAOImpl instance = new CompanyDAOImpl();
        Company expResult = null;
        Company result = instance.find(id);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of findAll method, of class CompanyDAOImpl.
     */
    public void testFindAll() {
        System.out.println("findAll");
        CompanyDAOImpl instance = new CompanyDAOImpl();
        List expResult = null;
        List result = instance.findAll();
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }
}
